package com.example.leetcode.leetcode;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * @author zht
 * @date 2021/1/7 17:35
 */
public class Solution448 {
    public static List<Integer> findDisappearedNumbers(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            int index = Math.abs(nums[i]) - 1;
            if (nums[index] > 0) {
                nums[index] *= -1;
            }
        }
        System.out.println(Arrays.toString(nums));
        List<Integer> result = new LinkedList<>();
        for (int i = 1; i <= nums.length; i++) {
            if (nums[i-1] > 0) {
                result.add(i);
            }
        }
        return result;
    }

    public static void main(String[] args) {
        int[] orl = new int[]{4, 3, 2, 7, 8, 2, 3, 1};
        System.out.println(findDisappearedNumbers(orl));
    }
}
